package com.yupi.oj.controller;

import com.yupi.oj.common.ErrorCode;
import com.yupi.oj.exception.BusinessException;
import com.yupi.oj.model.entity.Question;
import com.yupi.oj.service.RecommendService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author FengHuan Wang
 * @Date 2025/3/13 14:09
 * @Version 1.0
 */

@RestController
@RequestMapping("/recommend")
public class RecommendController {

    @Resource
    private RecommendService recommendService;

    @PostMapping("/{id}")
    public List<Question> doRecommend(@PathVariable Long id){
        if (id == null){
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数错误");
        }
        List<Question> questionList = recommendService.doRecommend(id);
        return questionList;
    }
}
